home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu330.dms / pu330.adf / SafeDelete / SafeDelete.doc < prev    next >
Text File  |  1992-09-14  |  16KB  |  372 lines

  1.  
  2.  
  3.                              SAFE DELETE
  4.                             ~~~~~~~~~~~~~
  5.                      ©Copyright Chris Watson 1992
  6.  
  7. 1. Summary
  8. ~~~~~~~~~~
  9.  
  10. This program provides a patch for the AmigaDOS library delete function
  11. so that any deletions operate in a similar manner to the workbench
  12. Trashcan.  When a file is deleted it is moved into a trashcan
  13. directory from where it can later be deleted.  A list of files can be
  14. specified, using the full pattern matching system which are actually
  15. deleted rather than moved.  This program requires at least version
  16. 2.04 of kickstart and workbench.
  17.  
  18.  
  19. 2. Using Safe Delete
  20. ~~~~~~~~~~~~~~~~~~~~
  21.  
  22. 2.1. Trashcan location
  23.  
  24. The trash directory can be placed anywhere and can be absolute,
  25. relative to the volume or relative to the directory.  Any relative
  26. trashcans are relative to the file being deleted and not the current
  27. directory of the calling program.  The location is set using the
  28. `TRASH' environment variable, simply use SetEnv to set this to the
  29. required directory path, there is no need to end the path with a `/'.
  30. If this variable does not exist then the default directory
  31. `SYS:Trashcan' is used.  If the specified directory does not exist
  32. then it is created.  The trashcan directory can be on any volume and
  33. can be on a different volume to a file.  My own preference is to use
  34. one central directory, 'SYS:Trashcan', so I always know where a
  35. deleted file will be and cleaning out the directory is made simpler
  36. since there is only one.  For maximum speed a RAM: or RAD: based
  37. trashcan could be used which does reduce the lifetime of deleted files
  38. to between reboots or power-downs.  On a floppy based system you
  39. should make the trashcan directory relative to the current volume,
  40. otherwise a deletion will take far too long to be worthwhile.
  41.  
  42.  
  43. 2.2. Temporaries list
  44.  
  45. The temporaries list is a list of files which should be deleted
  46. completely rather than being moved.  This list consists of a set of
  47. patterns against which the file is compared, if a match is made then
  48. the file is deleted properly.  This list includes not only files but
  49. directories as well, thus files in a temporary directory such as T:
  50. or trashcan can be deleted, as normal.  This temporary list is
  51. entirely at the discretion of the user, if no patterns are placed in
  52. it then all files are moved, including files, which are already in the
  53. trashcan directory.  The included .info sets the temporary files and
  54. directories which I use, the command line given under installation
  55. gives the same set of patterns from the command line.
  56.  
  57. The pattern match is case-less and before being matched the file name
  58. is expanded to an absolute path, which includes the volume name and
  59. not the drive name, i.e. floppy:file rather than df0:file or
  60. RAMDISK:T/tmp rather than T:tmp.  This means that the temporaries list
  61. needs to specify only the one absolute path against which it can be
  62. compared rather than a number of relative paths.
  63.  
  64. When inserting a directory or file into the temporary list the
  65. possible locations it may exist in and the way they interact with the
  66. pattern matching techniques must be considered.  For example, any file
  67. which has an extension of .tmp may be detected if it is added to the
  68. temporaries list as #?.tmp.  However, any file which begins with
  69. CygnusEd may only be detected by using all its possible paths i.e.
  70. #?(/|:)CygnusEd is required, the same applies to directories.  If you
  71. are in any doubt as to which expansion to perform then simply use the
  72. Add option from the windowing interface and examine the patterns that
  73. it inserts, and if you wish insert them into your startup call to
  74. SafeDelete.
  75.  
  76.  
  77. 2.3. Installation
  78.  
  79. The DeleteFile replacement function can be installed simply by running
  80. the SafeDelete program from the CLI or Workbench.  The program sets up
  81. a list of temporaries and patches the dos library.  The program does
  82. not remain in memory, although the patch and temporaries list do, this
  83. means that the memory overhead is small, about 1k.  If you wish to run
  84. SafeDelete at startup time, which is the best time to run it, then
  85. either drop it into the WBStartup drawer or place it into your
  86. User-Startup file.
  87.  
  88. The initial temporaries list can be set easily.  From the CLI type the
  89. file name and path and the list of temporaries to use, as an example,
  90. to get the same set of temporaries as the included .info file:
  91.  
  92.     SafeDelete #?.tmp #?(:|/)T/#? #?(/|:)Trashcan/#? #?(:|/)CygnusEd?.???
  93.  
  94. To setup the initial temporaries list from the Workbench add each item
  95. as a tool type they can be entered directly e.g. #?.tmp or with an
  96. initial ADD='s statement, thus ADD=#?.tmp.
  97.  
  98. The method that SafeDelete uses to ascertain if the library has
  99. already been patched by SafeDelete is to check for the existence of
  100. the `SafeDelete' environment variable.  If your environment directory
  101. is permanent, whether between cold reboots or full power-downs, then
  102. the program will only be installed once.  To get round this the FORCE
  103. keyword can be used, it can be specified on the CLI command line, as
  104. FORCE, or in the workbench tool types, as FORCE=.  If the force
  105. keyword occurs in the arguments to the SafeDelete program then it will
  106. always patch the dos library.
  107.  
  108.  
  109. 2.4. CLI Interface
  110.  
  111. If SafeDelete is invoked from the CLI or shell then it has the
  112. following template, giving a question mark, ?, as an option brings up
  113. this template and doing so again brings up further help:
  114.  
  115.                  SafeDelete KILL/S,FORCE/S,ADD/M,REMOVE/F/K
  116.  
  117. SafeDelete performs a range of possible actions based upon the command
  118. line options and whether or not it is already installed.  If it is not
  119. already installed or the FORCE option is specified, then it installs
  120. itself and uses the arguments to ADD, which are optional, as the
  121. initial temporaries list.
  122.  
  123. If KILL is specified and it is already installed then it will attempt
  124. to remove the patch from the dos library and deallocates the memory
  125. used.  Care must be taken that no programs are currently executing the
  126. Safe Delete code and no other instances of SafeDelete or its child
  127. processes are running, but see also the section on other dos library
  128. patching programs.  If ADD is specified, and/or one or more patterns
  129. are given, then the patterns are inserted into the temporaries list.
  130. Note unlike the Window Add option this inserts only the specified
  131. patterns it does not expand them in any way.
  132.  
  133. If REMOVE is specified then any patterns following the REMOVE keyword
  134. are deleted from the temporaries list.  If you wish to delete patterns
  135. then REMOVE must be specified and as can be seen from the template the
  136. REMOVE option absorbs anything on the command line after it, so REMOVE
  137. and its patterns should always be specified last.
  138.  
  139. Finally, if no options are specified and the patch has already been
  140. installed then the windowing interface is called and the program
  141. detaches from the CLI, allowing it to be closed or other programs to
  142. be run from it.
  143.  
  144.  
  145. 2.5. Workbench Interface
  146.  
  147. SafeDelete can be called from the Workbench, if it is not installed or
  148. the FORCE tool type is specified then it uses the tool types as a set
  149. of initial temporaries, again like the CLI ADD argument, these are not
  150. expanded in any way.
  151.  
  152. If the program has already been installed then the windowing interface
  153. is opened.  In this case the tool types are ignored.
  154.  
  155.  
  156. 2.6. Windowing Interface
  157.  
  158. The windowing interface offers an interactive means of controlling and
  159. examining the temporaries list and of removing the patch.  It is
  160. started from the workbench any time that the SafeDelete program is
  161. run, the patch has already been applied and there is no FORCE tool
  162. type.  From the CLI it is started if there are no command line options
  163. and the patch has already been applied.
  164.  
  165. The window which opens has a list gadget which contains a list of all
  166. the temporary patterns and four gadgets; Add, Remove, Done and Kill.
  167. The Done gadget closes the window and exits the program, the window
  168. close gadget also has the same effect.  The Kill gadget removes the
  169. patch and exits the program.  The Remove gadget is ghosted until a
  170. pattern entry is selected, the selected entry will then appear in the
  171. box below the main list and clicking on remove will delete it from the
  172. temporaries list.
  173.  
  174. The Add gadget is used to add new pattern entries into the temporaries
  175. list, when it is clicked an file requester will appear.  Select the
  176. file patterns from the requester or type them into the string gadgets,
  177. wildcards may be entered by typing them into the string gadgets.  A
  178. filename, a directory or both a filename and a directory may be
  179. entered, the program will then expand the entered pattern to account
  180. for all delete possibilities.
  181.  
  182.  
  183. 2.7. Cleaning out the Trashcan directory
  184.  
  185. No special tools are required to delete the contents of your trashcan
  186. directory, all that is required is for the directory to be included as
  187. part of the temporaries list then any delete program will correctly
  188. delete the contents.  If you wish to empty the contents on startup
  189. simply insert:
  190.  
  191.                       delete SYS:Trashcan/#? ALL QUIET
  192.  
  193. in your User-Startup either before or after SafeDelete has been
  194. installed or alternatively PurgeTrash can be used, in order to limit
  195. the growth of the trashcan.
  196.  
  197.  
  198. 3. Other Programs
  199. ~~~~~~~~~~~~~~~~~
  200.  
  201. 3.1. WildStar
  202.  
  203. WildStar allows the asterisk, *, to be used as a wildcard in place of
  204. the #? wildcard.  Invoking WildStar toggles the status of the *, so
  205. that one use will allow it and the next will stop its use.  Since, the
  206. Shell uses * to represent the current console, an asterisk on its own
  207. will still refer to the rather than the list of files, thus type *
  208. will allow input to be typed in the console which is echoed, rather
  209. than typing the contents of all the files in the current directory as
  210. #? would.  The star can be used in normal directory paths such as /*
  211. with no problems, but if it's used on its own then two should be used
  212. i.e. ** is the same as #?, whilst :* is the same as :#?.
  213.  
  214.  
  215. 3.2. PurgeTrash
  216.  
  217. PurgeTrash is used to delete the contents of the trashcan, files are
  218. deleted based on their age, the size of the trashcan or both.  It uses
  219. the following template:
  220.  
  221.                 SIZE/N,DAYS/N,DIR/S,CONTINUE/S
  222.  
  223. If a size is given then files are deleted, oldest first, from the
  224. trashcan in order to reduce it to that size, in bytes.  For example:
  225.  
  226.                 PurgeTrash SIZE 1000000
  227.  
  228. would restrict the trashcan to a size of 1 megabyte.  If days is given
  229. then files older than that date are deleted, for example:
  230.  
  231.                 PurgeTrash DAYS 7
  232.  
  233. would delete all the files in a trashcan over 1 week old.  If both are
  234. given then it deletes only files older than the specified date and
  235. which cause the trashcan to be larger than the specified size.  For
  236. example:
  237.  
  238.                 PurgeTrash SIZE 1000000 DAYS 7
  239.  
  240. would delete all the files in the trashcan which are over 1 week old
  241. and which caused the trashcan to be too large.  It would not, however,
  242. delete files which were less than 7 days old even if the trashcan was
  243. too big.  Thus, files may be present in the trashcan which are older
  244. than expected and the trashcan may be larger than expected.  If the
  245. DIR switch is present then any empty directories will be deleted, this
  246. occurs during the scanning phase, so directories which are emptied as
  247. the result of deletions by this program are ignored, however, they
  248. will be deleted the next time PurgeTrash is run.  If the CONTINUE
  249. switch is present then the program will continue if a file fails to
  250. delete, although it is considered to have been deleted for the
  251. purposes of reducing the size of the trashcan.  The program to
  252. defaults to deleting all files over 7 days old, not deleting empty
  253. directories and stopping on an error.
  254.  
  255. The program can also be called from the workbench, all the command
  256. line arguments are supported as tool types, so `SIZE=<num>',
  257. `DAYS=<num>', `DIR' and `CONTINUE' can all be present as tool types.
  258.  
  259.  
  260. 3.3. RetTrash
  261.  
  262. RetTrash retrieves a file from the trashcan, its template is:
  263.  
  264.                 FROM/M,TO/A,ALL/S,BUF=BUFFER/K/N,QUIET/S
  265.  
  266. FROM is a list of files which are to be retrieved, sub-directories
  267. within the trashcan may be specified and wildcards may be used for the
  268. name of the file, although not for any directory specifier.  TO
  269. indicates to which directory/filename the file is to be moved,
  270. wildcards are not supported for this argument "" and a single dot `.'
  271. can be used to represent the current directory and two dots `..' can
  272. be used to represent the parent directory.  ALL indicates that a full
  273. directory structure should be moved, if ALL is not present then
  274. directories are ignored.  BUFFER gives the size of buffer to use in
  275. 512 byte blocks.  By default 200 blocks are used, 100k, if buffer is 0
  276. then a buffer the same size as the file is allocated.  If QUIET is
  277. present then messages indicating the status of the retrieval are not
  278. displayed although error messages are.  The program also copies the
  279. date, protection bits and comments of the trashcan file.
  280.  
  281. It should be emphasised that the files in the trashcan are normal
  282. AmigaDOS files and both RetTrash and PurgeTrash are provided as
  283. convenient tools for accessing the trashcan, it is not necessary to
  284. use them.
  285.  
  286.  
  287. 4. Notes
  288. ~~~~~~~~
  289.  
  290. 4.1. Other Dos library patching programs
  291.  
  292. There are other programs which patch dos library, such as SnoopDos,
  293. this patch should be transparent to them; but the patches should be
  294. removed in reverse order to their order of insertion.  So, if SnoopDos
  295. is run before SafeDelete, then SafeDelete must be killed before
  296. SnoopDos.
  297.  
  298.  
  299. 4.2. Pre-v2 Filing Systems
  300.  
  301. The SafeDelete patch users the NameFromLock function, some filing
  302. systems which pre-date version 2 do not support this, such as
  303. MessyDos.  In such cases the file will be deleted but the patterns may
  304. not work the way you expect, since the major effect of the lack of
  305. this call is that filenames are not expanded to their full and correct
  306. absolute path.  The files are deleted based on the name passed by the
  307. calling program, in the case of the Dos Delete command only the file
  308. name is passed in, thus any paths in the pattern will probably be
  309. ignored.
  310.  
  311.  
  312. 4.3. Compressing this Program
  313.  
  314. If you are using a floppy based system then it is worth crunching the
  315. SafeDelete program using a utility such as PowerPacker or Imploder.
  316. Simple tests indicate that PowerPacker v3.0b in it's best mode is
  317. better than Imploder v4.0.  Both of them do reduce file size and
  318. loading time.
  319.  
  320. 4.4. Deletion Programs
  321.  
  322. The patch works with any program which performs deletions through the
  323. Dos Library delete function call; such as SID, DirWork and the
  324. ToolManager DeleteTool program, but not the 1.3 Delete command.  As an
  325. added bonus to users of Cygnus Ed if a file is saved using the `safe
  326. save' option then the previous version is automatically backed up,
  327. which reduces the clutter of .bak files which occur with the normal
  328. backup option.
  329.  
  330.  
  331. 5. Distribution and Contribution
  332. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333.  
  334. This program is shareware and a fee of £5 (sterling) is charged for
  335. usage after a 30 day evaluation period.
  336.  
  337. It can be distributed for no more than a nominal fee which covers
  338. distribution and copying.  This program may be included in any
  339. library, specific permission is given for its inclusion in the Fred
  340. Fish library.  The distribution set of files may not be changed.
  341.  
  342.  
  343. 6. Acknowledgements
  344. ~~~~~~~~~~~~~~~~~~~
  345.  
  346. Thanks to Steve Watts for the original inspiration for this program on
  347. Unix and Uwe Schuerkamp for nodelete which showed that patching the
  348. dos library was feasible.
  349.  
  350. Eddy Carroll whose subroutine Res.a provided the means of writing the
  351. subroutine which allowed SafeDelete to detach itself.
  352.  
  353.  
  354. 7. Addresses
  355. ~~~~~~~~~~~~
  356.  
  357. Email as:
  358.     cw@olympus.cs.hull.ac.uk - preferable
  359. or
  360.     cwatson@compulink.co.uk
  361.  
  362.  
  363. Normal mail as, although email is far more convenient:
  364.  
  365.     Chris Watson
  366.     82a Morthen Road,
  367.     Wickersley,
  368.     Rotherham,
  369.     South Yorkshire,
  370.     S66 0EG,
  371.     Britain.
  372.